import org.junit.Test;

import static org.junit.Assert.*;

public class NGuessNumberTest {
    NGuessNumber nGuessNumber = new NGuessNumber();

    @Test
    public void generateAnswerTest(){
        int[] arr = nGuessNumber.generateAnswer();//获取4个数字

        assert arr.length==4:"答案数字数量不为4";//判断数量是否为4

        int num1=arr[0],num2=arr[1],num3=arr[2],num4=arr[3];

        boolean a =(num1==num2||num1==num3||num1==num4||num2==num3||num2==num4||num3==num4);//判断是否重复
        assert a!=true:"有重复数字";

        boolean b = num1>=0&&num1<=9 && num2>=0&&num2<=9 && num3>=0&&num3<=9 && num4>=0&&num4<=9;//判断是否0-9内
        assert b==true:"数字不在0-9之间";
    }

    @Test
    public void getPlayerInputTest(){
        int[] arr = nGuessNumber.getPlayerInput();//获取4个数字
        assert arr.length==4:"答案数字数量不为4";//判断数量是否为4
    }

    @Test
    public void compareGuessAnswerTest(){
        nGuessNumber.compareGuessAnswer(nGuessNumber.generateAnswer(), nGuessNumber.getPlayerInput());
    }

    @Test
    public void isWinTest(){
        int a = nGuessNumber.compareGuessAnswer(nGuessNumber.generateAnswer(), nGuessNumber.getPlayerInput());
        if (4==a){
            assert true==nGuessNumber.isWin(a):"提示为4A，isWin返回值不为true";
        }else{
            assert true!=nGuessNumber.isWin(a):"提示并非4A，isWin返回值为true";
        }

    }


}